package com.zwj.controller;

import com.zwj.bo.*;
import com.zwj.entity.UserEntity;
import com.zwj.service.TeamService;
import com.zwj.utils.TokenUtils;
import com.zwj.vo.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/team")
public class TeamController  {
    private final TeamService teamService;
    public TeamController(TeamService teamService) {
        this.teamService = teamService;
    }
    @ApiOperation(value = "添加分组", notes = "添加分组")
    @PostMapping("/addTeam")
    public Result addTeam(@RequestBody TeamBo teamBo, HttpServletRequest request) {
        UserEntity userEntity = TokenUtils.getUser(request);
        return teamService.addTeam(teamBo,userEntity);
    }
    @ApiOperation(value = "查询项目组", notes = "查询项目组")
    @PostMapping("/selectTeam")
    public Result selectTeam(@RequestBody SelectTeamBo selectTeamBo) {
        return teamService.selectTeam(selectTeamBo);
    }
    @ApiOperation(value = "编辑项目组", notes = "编辑项目组")
    @PostMapping("/updateTeam")
    public Result updateTeam(@RequestBody  SelectTeamBo selectTeamBo, HttpServletRequest request) {
        UserEntity userEntity = TokenUtils.getUser(request);
        return teamService.updateTeam(selectTeamBo,userEntity);
    }
    @ApiOperation(value = "删除项目组", notes = "删除项目组")
    @PostMapping("/deleteTeam")
    public Result deleteTeam(@RequestBody  DeleteTeamBo deleteTeamBo, HttpServletRequest request) {
        UserEntity userEntity = TokenUtils.getUser(request);
        return teamService.deleteTeam(deleteTeamBo,userEntity);
    }
    @ApiOperation(value = "查询分组成员", notes = "查询分组成员")
    @PostMapping("/selectTeamStudent")
    public Result selectTeamStudent(@RequestBody SelectTeamStudentBo selectTeamStudentBo) {
        return teamService.selectTeamStudent(selectTeamStudentBo);
    }
    @ApiOperation(value = "项目组添加成员", notes = "项目组添加成员")
    @PostMapping("/addTeamStudent")
    public Result addTeamStudent(@RequestBody AddTeamStudentBo addTeamStudentBo, HttpServletRequest request) {
        UserEntity userEntity = TokenUtils.getUser(request);
        return teamService.addTeamStudent(addTeamStudentBo,userEntity);
    }
    @ApiOperation(value = "设置取消组长", notes = "设置取消组长")
    @PostMapping("/setTeamStudentLeader")
    public Result setTeamStudentLeader(@RequestBody SetTeamStudentLeaderBo setTeamStudentLeaderBo, HttpServletRequest request) {
        UserEntity userEntity = TokenUtils.getUser(request);
        return teamService.setTeamStudentLeader(setTeamStudentLeaderBo,userEntity);
    }
    @ApiOperation(value = "删除项目组学生 批量单个都行", notes = "删除项目组学生 批量单个都行")
    @PostMapping("/deleteTeamStudent")
    public Result deleteTeamStudent(@RequestBody DeleteTeamStudentBo deleteTeamStudentBo, HttpServletRequest request) {
        UserEntity userEntity = TokenUtils.getUser(request);
        return teamService.deleteTeamStudent(deleteTeamStudentBo,userEntity);
    }
    @ApiOperation(value = "更换项目组学生 批量单个都行", notes = "更换项目组学生 批量单个都行")
    @PostMapping("/setStudentTeam")
    public Result setStudentTeam(@RequestBody SetStudentTeamBo setStudentTeamBo, HttpServletRequest request) {
        UserEntity userEntity = TokenUtils.getUser(request);
        return teamService.setStudentTeam(setStudentTeamBo,userEntity);
    }
}
